<!DOCTYPE html>
<#import "/common/common.html" as common>
<html>
<head>
	<@common.head title="基础权限框架-用户管理" keywords="" description=""/>
</head>
<body class="gray-bg">

    <div class="wrapper wrapper-content animated fadeInRight">
    	<div class="row">
            <div class="col-sm-12" id="userListDiv">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                    	 <!-- 操作按钮 -->
						<div class="rboor" id="toolbar">
							<button id="add" onclick="add()" class="btn btn-primary"><i class="fa fa-plus"></i> 新增</button>
							<button id="edit" onclick="edit()" class="btn btn-info"><i class="fa fa-pencil"></i> 编辑</button>
							<button id="remove" onclick="remove()" class="btn btn-danger"><i class="fa fa-trash"></i> 删除</button>
							<!-- 
							<button id="search" onclick="search()" class="btn btn-warning"><i class="fa fa-search"></i> 条件查询</button>
							<div class="btn-group">
							  <button id="permissions" type="button" class="btn btn-primary"><i class="fa fa-key"></i> 权限设置</button>
							  <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
							    <span class="caret"></span>
							  </button>
							  <ul class="dropdown-menu">
							    <li><a href="javascript:void(0)" id="role" onclick="role()">用户角色</a></li>
							    <li><a href="javascript:void(0)" id="permission" onclick="permission()">用户权限</a></li>
							  </ul>
							</div>		
							 -->
					    </div>
                         <table id="table"
                         	   data-toolbar="#toolbar"
				               data-show-refresh="false"
					           data-show-toggle="true"
					           data-show-columns="true"
					           data-show-export="true"
				               data-url="${basePath}/user/pageList"
				               data-id-field="id"
				               data-click-to-select="true"
				               data-side-pagination="server"
				               data-pagination="true"
				               data-icon-size="outline"
				               data-show-refresh="true"
				               data-show-columns="true"
				               data-show-export="true" 
				               data-show-toggle="true"
				               data-page-list="[5, 10, 20, 50, 100]"
				               data-pagination-first-text="首页"
							   data-pagination-pre-text="上一页"
							   data-pagination-next-text="下一页"
							   data-pagination-last-text="末页"
				               >
				        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 新增/编辑 窗口 -->
    <@common.remoteModal class="modal-lg"/>
    
    <!-- Page-Level Scripts -->
    <script>
	$(function () {
		list();
	});
	
	function list(){
		$('#table').bootstrapTable({
	        columns: [
                {
                    field: 'state',
                    checkbox: true,
                    align: 'center',
                    valign: 'middle'
                }, {
                    title: 'ID',
                    field: 'id',
                    align: 'left',
                    visible: false,
                    switchable: false,
                    valign: 'middle',
                    sortable: true
                }, {
                    title: '用户名',
                    field: 'username',
                    align: 'left',
                    valign: 'middle',
                    sortable: true
                }, {
                    title: '姓名',
                    field: 'realname',
                    align: 'left',
                    valign: 'middle',
	                sortable: true
                }, {
                    title: '手机号码',
                    field: 'mobile',
                    align: 'left',
                    valign: 'middle',
	                sortable: true
                }, {
                    title: '邮箱',
                    field: 'email',
                    align: 'left',
                    valign: 'middle',
	                sortable: true
                }, {
                    title: '性别',
                    field: 'gender',
                    align: 'left',
                    valign: 'middle',
                    sortable: true,
                    formatter: function(value, row, index){
	                	if(value) {
	                		return '男';
	                	}else {
	                		return '女';
	                	}
	                }
                }, {
                    title: '状态',
                    field: 'enabled',
                    align: 'left',
                    valign: 'middle',
	                sortable: true,
	                formatter: function(value, row, index){
	                	if(value) {
	                		return '<span class="label label-success">启用</span>';
	                	}else {
	                		return '<span class="label label-danger">禁用</span>';
	                	}
	                }
                }, {
                    title: '类型',
                    field: 'type',
                    align: 'left',
                    valign: 'middle',
	                sortable: true,
	                formatter: function(value, row, index){
	                	if(value == 1) {
	                		return '<span class="label label-success">管理员</span>';
	                	}else {
	                		return '<span class="label label-danger">业务员</span>';
	                	}
	                }
                }, {
                    title: '备注',
                    field: 'remark',
                    align: 'left',
                    visible: false,
                    valign: 'middle'
                }
	        ],
	        queryParams: function(params) {
	        	return params;
	        },
	        queryParamsType: "" // When requesting remote data, you can send additional parameters by modifying queryParams. If queryParamsType = 'limit', the params object contains: 
					// limit, offset, search, sort, order Else, it contains: 
	        		// pageSize, pageNumber, searchText, sortName, sortOrder. 
	        		// Return false to stop request.
    	}).on('check.bs.table uncheck.bs.table ' +
                'check-all.bs.table uncheck-all.bs.table', function () {
	    	//$("#edit").prop('disabled', $("#table").bootstrapTable('getSelections').length != 1);
            //$("#remove").prop('disabled', !$("#table").bootstrapTable('getSelections').length);
            //selections = getIdSelections();
        });

	    $(window).resize(function () {
	        $('#table').bootstrapTable('resetView');
	    });
	}
	
	// 新增
    <@common.simple url="${basePath}/user/goAdd"/>
    
    // 编辑
    <@common.single url="${basePath}/user/goEdit"/>

    // 删除
    <@common.remove url="${basePath}/user/remove"/>
    
    </script>
</body>

</html>